package main

import "fmt"

func main() {
	fmt.Println(minimumJumps([]int{8, 3, 16, 6, 12, 20}, 15, 13, 11))
}

func minimumJumps(forbidden []int, a int, b int, x int) (ans int) {
	m := make(map[int]struct{})
	for _, f := range forbidden {
		m[f] = struct{}{}
	}

	c := 0
	for {
		c += a
		if c == x {
			ans++
			return
		}
		_, ok := m[c]
		if ok || c > x {
			c -= b
			if c < 0 {
				return -1
			}
		}
		ans++
	}
}
